#include "homedevform.h"
#include "ui_homedevform.h"
#include <QSqlQueryModel>
#include <QDebug>

HomeDevForm::HomeDevForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::HomeDevForm)
{
    ui->setupUi(this);

    m_devInfoModel = new QSqlQueryModel(this);
    updateDevView();
}

HomeDevForm::~HomeDevForm()
{
    delete ui;
}

void HomeDevForm::updateDevView(void)
{
    m_devInfoModel->clear();
    m_devInfoModel->setQuery("select * from dev_info");
    m_devInfoModel->setHeaderData(0, Qt::Horizontal, tr("设备号"));
    m_devInfoModel->setHeaderData(1, Qt::Horizontal, tr("设备名"));
    m_devInfoModel->setHeaderData(2, Qt::Horizontal, tr("设备"));
    m_devInfoModel->setHeaderData(3, Qt::Horizontal, tr("安装位置"));

    ui->tableView->setModel(m_devInfoModel);
}
